home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / cenvid.zip / PATHDEL.BAT < prev    next >
DOS Batch File  |  1993-03-20  |  1KB  |  45 lines

  1. @echo off
  2. REM PathDel.bat - remove a directory from the current path, if it's there
  3. if "%1"=="" GOTO SHOW_HOW
  4. if not "%2"=="" GOTO SHOW_HOW
  5. cenvi %0.BAT %1
  6. GOTO FINI
  7.  
  8. :SHOW_HOW
  9. ECHO PathDel.bat - Delete a directory from the PATH if it's there
  10. ECHO USAGE: PathDel DirSpec
  11. GOTO FINI
  12.  
  13.  
  14. GOTO CENVI_EXIT
  15.  
  16. main(argc,argv)
  17. {
  18.    OldDir = argv[1]
  19.    if NULL == (Position = FindDirInPath(OldDir))
  20.       printf("The Directory \"%s\" is not in PATH.\n",OldDir)
  21.    else {
  22.       // copy from Path beyond this dir
  23.       strcpy(Position,Position+strlen(OldDir))
  24.       // if there is a semi-colon at this position, then copy from beyond that too
  25.       if (Position[0] == ';')
  26.          strcpy(Position,Position+1)
  27.    }
  28. }
  29.  
  30. FindDirInPath(Dir) // search through path for this Dir, return pointer if found
  31.                    // and return NULL if not found
  32. {
  33.    len = strlen(Dir)
  34.    p = PATH
  35.    do {
  36.       if ( 0 == strnicmp(p,Dir,len)  && (p[len]==0 || p[len]==';') )
  37.          return(p)
  38.       p = strchr(p,';')
  39.    } while( p++ != NULL )
  40.    return(NULL)
  41. }
  42.  
  43. :CENVI_EXIT
  44. :FINI
  45.